<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="java.util.*"%>
<%@ page import="kau.vo.*"%>
<%@ page import="kau.dao.*"%>
<%@ page import="java.text.SimpleDateFormat"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>


<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$("#searchBt")
								.click(
										function() {

											var searchWord = $("#searchWord")
													.val();
											var searchForm = $("#searchForm");
											if (searchWord == ''
													|| searchWord == null) {
												alert("검색어를 입력해주세요");
												return;
											}

											var searchIndex = $("#searchSelect")
													.val();
											if (searchIndex == 1) {
												searchForm
														.attr(
																'action',
																"searchList.writing?searchIndex=1&bNumber=${requestScope.bNumber}&courseId=${param.courseId}");
												searchForm.submit();
											} else if (searchIndex == 2) {
												searchForm
														.attr(
																'action',
																"searchList.writing?searchIndex=2&bNumber=${requestScope.bNumber}&courseId=${param.courseId}");
												searchForm.submit();
											} else if (searchIndex == 3) {
												searchForm
														.attr(
																'action',
																"searchList.writing?searchIndex=3&bNumber=${requestScope.bNumber}&courseId=${param.courseId}");
												searchForm.submit();

											} else {
												alert("searchIndex error");
											}
										});
					}

			);
</script>

<script src="http://code.jquery.com/jquery.js"></script>
<link rel="stylesheet" href="/nems/writing/css/style.css">
</head>
<body >

<br>	
 <div  align="left" style="display:table;border-bottom:2px solid #d6d6d6; width:700px ; height:10px;">
		
		<img alt="" src="/nems/writing/img/notice.gif">
		
		<font style="font-weight: bolder;font-family: 맑은고딕">${requestScope.title}
		</font>
		
</div>
 	
 	
 	

	<br>
 	<table width='700px'>
		<tr>
		
			<td colspan="5" align=right>
				<font style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif;font-size:12px">글 개수
					:${fn:length(writingList)}</font>
			</td>
		</tr>
	</table>
	





	<table id="gradient-style" summary="Meeting Results" width="700px">
		<thead>
			<tr height="30px">
				<th scope="col" width="10%">번호</th>
				<th scope="col" width="45%">제목</th>
				<th scope="col" width="20%">날짜</th>
				<th scope="col" width="15%">작성자</th>
				<th scope="col" width="10%">조회수</th>
			</tr>
		</thead>
		<tbody align="center">

			<c:set value="${requestScope.replyCountList }" var="replyCountList">
			</c:set>
			<c:forEach items="${requestScope.writingList}" var="writing"
				varStatus="status">
				<tr>
					<td><font style="font-size: 12px">${requestScope.listcount - (requestScope.page -1)*10 - status.index}</font></td>
					<td align="left"><a
						href="./showWriting.writing?wNumber=${writing.wNumber}&bNumber=${requestScope.bNumber}&courseId=${param.courseId}"
						style="text-decoration: none; color: black;"> <font style="font-size: 12px">&nbsp;&nbsp;${writing.title}</font>
							<c:if test="${replyCountList[status.index]!=0}">
								<font style="font-size: 12px">(${replyCountList[status.index]})</font>
							</c:if>
					</a>
						<c:if test="${not empty writing.filePath}">
								<img src='/nems/writing/img/icon_file.gif'>
							</c:if>
					
					</td>
					<td><font style="font-size: 12px">${writing.writeTime}</font></td>
					<td><font style="font-size: 12px">${writing.writer}</font></td>

					<td><font style="font-size: 12px">${writing.hits}</font></td>
				</tr>

			</c:forEach>


			<tr align="right">
				<td colspan="5">
				<c:if
					test="${4-requestScope.writingPermission >=sessionScope.level}">
					<a
						href="./writeView.writing?bNumber=${requestScope.bNumber}&courseId=${param.courseId}"><img alt="글쓰기" src="/nems/writing/img/write.png" border="0"></a>	
				</c:if>
				</td>
			</tr>
		</tbody>
	</table>

	<table width='700px'>
		<tr>

				<td colspan="5" align="center"><br />
					<form id="searchForm" action="#" method="post">
						<select id="searchSelect">
							<option value="1">작성자</option>
							<option value="2">제목</option>
							<option value="3">내용</option>
						</select> <input type="text" name="searchWord" id="searchWord" />
							<a name="searchBt" id="searchBt" href="#" >
								<img alt="검색" src="/nems/writing/img/zoom.png" border="0">
							</a>
							<a href="list.writing?bNumber=${requestScope.bNumber }" ><img alt="리셋" src="/nems/writing/img/arrow_refresh.png" border="0"></a>
							</td>
					</form>
			</tr>
	
	
		<tr>
			<td align="center" valign="middle"><c:if
					test="${requestScope.page<=1 }">
					<img src="/nems/writing/img/prev.gif">&nbsp;
				</c:if> <c:if test="${requestScope.page>1 }">
					<c:if test="${empty requestScope.searchIndex }">
						<a
							href="./list.writing?page=${requestScope.page-1 }&bNumber=${requestScope.bNumber }&courseId=${param.courseId}"><img
							src="/nems/writing/img/prev.gif" border="0"></a>&nbsp;
					</c:if>
					<c:if test="${not empty requestScope.searchIndex }">
						<a
							href="./searchlist.writing?page=${requestScope.page-1 }&bNumber=${requestScope.bNumber }&searchIndex=${requestScope.searchIndex}&courseId=${param.courseId}"><img
							src="/nems/writing/img/prev.gif" border="0"></a>&nbsp;
					</c:if>
				</c:if> <c:forEach begin="${requestScope.startpage }"
					end="${requestScope.endpage}" var="pageNum" step="1">
					<c:if test="${pageNum==requestScope.page }">
						<font style="font-size: 13px; color: black;">[<font
							color="red">${pageNum}</font>] &nbsp;
						</font>
					</c:if>
					<c:if test="${pageNum != requestScope.page }">
						<c:if test="${empty requestScope.searchIndex }">
							<a
								href="./list.writing?page=${pageNum}&bNumber=${requestScope.bNumber}&courseId=${param.courseId}"
								style="text-decoration: none; color: black;"><font
								style="font-size: 13px">[${pageNum}]</font> </a> &nbsp;								
						</c:if>
						<c:if test="${not empty requestScope.searchIndex }">
							<a
								href="./searchList.writing?page=${pageNum}&bNumber=${requestScope.bNumber}&searchIndex=${requestScope.searchIndex}&courseId=${param.courseId}" style="text-decoration: none; color: black;"><font
								style="font-size: 13px">[${pageNum}]</font> </a> &nbsp;								
						</c:if>
					</c:if>

				</c:forEach> <c:if test="${requestScope.page >= requestScope.maxpage }">
					<img src="/nems/writing/img/next.gif" border="0">
				</c:if> <c:if test="${ requestScope.page < requestScope.maxpage}">
					<c:if test="${empty requestScope.searchIndex }">
						<a
							href="./list.writing?page=${requestScope.page+1}&bNumber=${requestScope.bNumber}&courseId=${param.courseId}"><img
							src="/nems/writing/img/next.gif" border="0"></a>
					</c:if>
					<c:if test="${not empty requestScope.searchIndex }">
						<a
							href="./searchList.writing?page=${requestScope.page+1}&bNumber=${requestScope.bNumber}}&searchIndex=${requestScope.searchIndex}&courseId=${param.courseId}"><img
							src="/nems/writing/img/next.gif" border="0"></a>
					</c:if>

				</c:if></td>



		</tr>
	</table>
</body>
</html>